
#include <fstream>
#include "Utility.h"
#include "Employee.h"

/*
 * Create list student
 * param: l list student 
 */
void CreateList(List *pList)
{
	pList->pHead = NULL;
	pList->pTail = NULL;
}


/*
 * Create Node student
 * param: x list student 
 */
Node *CreateNode(CEmployee *pEmployee)
{
	Node *pNode;
	pNode = new Node;
	pNode->info = pEmployee;
	pNode->pNext = NULL;
	return pNode;
}

//End action of every case input
void End()
{
	printf("-----------DONE!-------------\n");		
	getch();
	system("cls");
}

// Show menu of program
void Menu()
{
	cout << "--------------HR Manage System------------------" << endl;
	cout << "\t1.Input Employee" <<endl;
	cout << "\t2.Input Employee Manual" <<endl;
	cout << "\t3.Write list employee to file" <<endl;
	cout << "\t4.Sort list employee belong to birthday" <<endl;
	cout << "\t5.Sort list employee belong to salary" <<endl;
	cout << "\t6.Remove employees have not address from Ha Noi" <<endl;
	cout << "\t7.Display list employee" <<endl;
	cout << "\t0.Quit" <<endl;
}

/*
 * Add student to head
 * param: l list student 
 * param: p node pointer add to list 
 */
void AddHead(List *pList, Node *pNode)
{
	if (pList->pHead == NULL)
	{
		pList->pHead = pNode;
		pList->pTail = pList->pHead;
	}
	else
	{
		pNode->pNext = pList->pHead;
		pList->pHead = pNode;
	}
}

/*
 * Add student to tail
 * param: l list student 
 * param: p node pointer add to list 
 */
void AddTail(List *pList, Node *pNode)
{
	if (pList->pHead == NULL)
	{
		pList->pHead = pNode;
		pList->pTail = pList->pHead;
	}
	else
	{
		pList->pTail->pNext = pNode;
		pNode->pNext = NULL;

	}

}
/*
 * Write to file
 * param: Plist list student  
 */
void WriteToFile( List *pList )
{
	ofstream f;
	f.open("Nhanvien.txt", ios::out);
	Node *pNode;
	pNode = pList->pHead;
	while (pNode != NULL)
	{
		pNode->info->WriteEmployee(f);
		pNode = pNode->pNext;
	}
	f.close();
}
